package com.qq.weixin.model.msg;

import java.util.Collection;
import java.util.concurrent.ArrayBlockingQueue;

import com.qq.weixin.enums.MsgType;

public class CusNewsMsg extends BaseCusMsg {
	private final MsgType msgtype = MsgType.news;

	private NewsObject news;

	public static CusNewsMsg create() {
		CusNewsMsg cusNewsMsg = new CusNewsMsg();
		cusNewsMsg.setNews(new NewsObject());
		return cusNewsMsg;
	}

	public static Article createArticle(String title, String description,
			String url, String picurl) {
		Article article = new Article();
		article.setDescription(description);
		article.setTitle(title);
		article.setUrl(url);
		article.setPicurl(picurl);
		return article;
	}

	public void addArticle(Article article) {
		if (this.getNews() == null) {
			this.setNews(new NewsObject());
		}
		this.getNews().getArticles().add(article);
	}

	public NewsObject getNews() {
		return news;
	}

	public void setNews(NewsObject news) {
		this.news = news;
	}

	public MsgType getMsgtype() {
		return msgtype;
	}

	public static class NewsObject {
		private final Collection<Article> articles = new ArrayBlockingQueue<Article>(
				10);

		public Collection<Article> getArticles() {
			return articles;
		}

	}

	public static class Article {
		private String title;
		private String description;
		private String url;
		private String picurl;

		public String getTitle() {
			return title;
		}

		public void setTitle(String title) {
			this.title = title;
		}

		public String getDescription() {
			return description;
		}

		public void setDescription(String description) {
			this.description = description;
		}

		public String getUrl() {
			return url;
		}

		public void setUrl(String url) {
			this.url = url;
		}

		public String getPicurl() {
			return picurl;
		}

		public void setPicurl(String picurl) {
			this.picurl = picurl;
		}

	}

}
